Parameter Configuration

SDK can access and configure device parameters via GenICam Standard Protocol, and provides a set of parameter configuration APIs commonly used for cameras and frame grabbers to get and set parameter nodes of 6 types (integer, enumeration, float, boolean, string, and command).

Node Name and Node Type Search

APIs of Node Getting and Setting nodes require configuring the node name and node type.
Therefore, before calling these APIs, you need to get the node name and node type via search on the client.
  1. Connect to the device via the client.

  2. Select a certain feature parameter on the client feature tree to view the parameter node information below the feature tree.

    Note
    If the client version is 4.4.0 or later, you can check calling example of node.

    The following is an example of the parameter Width.

    Check node information of width parameters.
Note
For more details, refer to the client user manual.

Node Getting and Setting

Refer to the sample code in this chapter to get and set node value in your program.
You can configure parameter nodes of 6 types: integer, enumeration, float, boolean, string, and command.
  • Integer Node:

    NodeName = "Width"
    # Get integer node
    stIntValue = MVCC_INTVALUE_EX()
    ret = cam.MV_CC_GetIntValueEx(NodeName ,stIntValue)
    if ret != 0:
    print ("MV_CC_GetIntValueEx fail! ret[0x%x]" % ret)
    sys.exit()
    # Set integer node
    ret = cam.MV_CC_SetIntValueEx(NodeName ,stIntValue.nCurValue)
    if ret != 0:
    print ("MV_CC_SetIntValueEx fail! ret[0x%x]" % ret)
    sys.exit()


  • Enumeration Node:

    NodeName = "PixelFormat";
    stEnumEntry = MVCC_ENUMENTRY()
    stEnumValue = MVCC_ENUMVALUE ()
    # Get enumeration node
    ret = cam.MV_CC_GetEnumValue(NodeName, stEnumValue)
    if ret != 0:
    print ("MV_CC_GetEnumValue fail! ret[0x%x]" % ret)
    sys.exit()
    # Get the symbol specified by the enumeration node
    stEnumEntry.nValue = stEnumValue.nCurValue;
    ret = cam.MV_CC_GetEnumEntrySymbolic(NodeName, stEnumEntry)
    if ret != 0:
    print ("MV_CC_GetEnumEntrySymbolic fail! ret[0x%x]" % ret)
    sys.exit()
    # Set enumeration node
    nRet = cam.MV_CC_SetEnumValue(NodeName ,stEnumValue.nCurValue)
    if ret != 0:
    print ("MV_CC_SetEnumValue fail! ret[0x%x]" % ret)
    sys.exit()
    # Set enumeration node via symbols
    strValue = "Mono8"
    ret = cam.MV_CC_SetEnumValueByString (NodeName, strValue)
    if ret != 0:
    print ("MV_CC_SetEnumValueByString fail! ret[0x%x]" % ret)
    sys.exit()


  • Float Node:

    NodeName = "ExposureTime"
    # Get float node
    FloatValue = MVCC_FLOATVALUE ()
    ret = cam.MV_CC_GetFloatValue(NodeName , FloatValue)
    if ret != 0:
    print ("MV_CC_GetFloatValue fail! ret[0x%x]" % ret)
    sys.exit()
    # Set float node
    ret = cam.MV_CC_SetFloatValue(NodeName , FloatValue.fCurValue)
    if ret != 0:
    print ("MV_CC_SetFloatValue fail! ret[0x%x]" % ret)
    sys.exit()


  • Boolean Node:

    NodeName = "GammaEnable"
    # Get boolean node
    bValue = ctypes.c_bool()
    ret = cam.MV_CC_GetBoolValue(NodeName , bValue)
    if ret != 0:
    print ("MV_CC_GetBoolValue fail! ret[0x%x]" % ret)
    sys.exit()
    # Set boolean node
    ret = cam.MV_CC_SetBoolValue(NodeName , bValue)
    if ret != 0:
    print ("MV_CC_SetBoolValue fail! ret[0x%x]" % ret)
    sys.exit()


  • String Node:

    NodeName = "DeviceUserID"
    # Get string node
    StringValue = MVCC_STRINGVALUE()
    ret = cam.MV_CC_GetStringValue(NodeName , StringValue)
    if ret != 0:
    print ("MV_CC_GetStringValue fail! ret[0x%x]" % ret)
    sys.exit()
    # Set string node
    newStringValue = "1234"
    ret = cam.MV_CC_SetStringValue(NodeName , newStringValue)
    if ret != 0:
    print ("MV_CC_SetStringValue fail! ret[0x%x]" % ret)
    sys.exit()


  • Command Node: Call MV_CC_SetCommandValue() to set command node.

    # Set command node
    NodeName = "UserSetLoad"
    ret = cam.MV_CC_SetCommandValue(NodeName)
    if ret != 0:
    print ("MV_CC_SetCommandValue fail! ret[0x%x]" % ret)
    sys.exit()


Exclusive Configuration of GigE Cameras

If you are using GigE cameras, you can set optimal packet size, and set resending packet.
  • Set Optimal Packet Size

    Before you start image acquisition after turning on the GigE camera, call MV_CC_GetOptimalPacketSize() to detect current network, and get optimal communication packet size.

    You can configure the packet size of image grabbing with this optimal packet size to improve the transmission speed of image grabbing.

    # Get optimal packet size (only supported by GigE devices)
    if stDeviceList.nTLayerType == MV_GIGE_DEVICE or stDeviceList.nTLayerType == MV_GENTL_GIGE_DEVICE:
    nPacketSize = cam.MV_CC_GetOptimalPacketSize()
    if int(nPacketSize) > 0:
    ret = cam.MV_CC_SetIntValue("GevSCPSPacketSize",nPacketSize)
    if ret != 0:
    print ("Warning: Set Packet Size fail! ret[0x%x]" % ret)
    else:
    print ("Warning: Get Packet Size fail! ret[0x%x]" % nPacketSize)
  • Set Resending Packet

    GigE Camera communicates data via network, so in some abnormal cases such as network congestion, data packet received from the SDK is incomplete. Resending command can control the device to resend the incomplete data.

    Attention
    • Resending packets supported by the camera are available.
    • For occasional network congestion, you can address occasional packet loss through resending.
    • For continuous network congestion, it is recommended to troubleshoot the exception and optimize the network. Enabling resending packet directly may result in worse network congestion. Use this feature with caution.
    • You can refer to the following sample codes and call MV_GIGE_SetResend() to enable resending packet.

      bEnable = True # Enable resending packet
      nMaxResendPercent= 100 # Set maximum resending percent
      nResendTimeout = 50 # Set resending timeout duration, unit: millisecond
      ret = cam.MV_GIGE_SetResend(bEnable, nMaxResendPercent, nResendTimeout)
      if ret != 0:
      print ("MV_GIGE_SetResend fail! ret[0x%x]" % ret)
      sys.exit()
      1. bEnable: Whether to enable resending packet
      2. nMaxResendPercent: Configure the maximum resending rate of the packet loss of the current frame. Do not resend the exceeding part to avoid worsening network congestion. When this value is set to 100, SDK will resend all packet loss of the current frame.
      3. nResendTimeout: Configure timeout duration of resending packet. Start counting time when the frame ends. If the counted time exceeds the set timeout, SDK will not request resending this packet loss data.
    • If the SDK does not receive data resent from the device, you need to control SDK to send the resending command again.

      You can refer to the following example, call MV_GIGE_SetResendTimeInterval() to control the interval of single resending packet, and call MV_GIGE_SetResendMaxRetryTimes() to configure maximum resending times.

      # Configure the interval of resending packet
      nMillisec = 10
      ret = cam.MV_GIGE_SetResendTimeInterval(nMillisec);
      if ret != 0:
      print ("MV_GIGE_SetResendTimeInterval fail! ret[0x%x]" % ret)
      sys.exit()
      # Configure maximum resending times
      nRetryTimes = 10
      ret = cam.MV_GIGE_SetResendMaxRetryTimes(nRetryTimes)
      if ret != 0:
      print ("MV_GIGE_SetResendMaxRetryTimes fail! ret[0x%x]" % ret)
      sys.exit()
      • nMillisec: It refers to the interval between two resending requests for one resending packet (10 ms by default).The shorter the interval is, the more network resources occupied by the resending packet are, increasing the pressure of network and device.
      • nRetryTimes: 20 by default. It represents that for single packet loss data, SDK can request resending command for 20 times at most.


Exclusive Configuration of U3V Cameras

If you are using USB3 vision device, you can adjust control channel, and stream channel to address corresponding exception.
  • Control channel is used to transmit control command. Abnormal control channel may result in slower execution of transmission control command. Therefore, the interface times out and an exception will be returned.

    You can refer to the following sample code, and call MV_USB_SetSyncTimeOut() to adjust the timeout duration of control channel, so as to be compatible with this type of exception.

    # Timeout duration (1 ms by default)
    Mills = 1000
    # Set timeout duration of sync reading and writing for USB3 vision cameras
    ret = cam.MV_USB_SetSyncTimeOut(Mills)
    if ret != 0:
    print ("MV_USB_SetSyncTimeOut fail! ret[0x%x]" % ret)
    sys.exit()
  • Stream channel is used to transmit image data. Insufficient bandwidth of stream channel or system resources may result in transmission failure and resource creation failure.

    You can refer to the following sample code, and call MV_USB_SetTransferSize() to adjust the image data packet size, or call MV_USB_SetTransferWays() to adjust the number of USB3 vision stream channels, so as to reduce resources occupied by SDK.

    # Set the maximum data packet size of USB3 vision camera
    TransferSize = 1*1024*1024
    ret = cam.MV_USB_SetTransferSize(TransferSize)
    if ret != 0:
    print ("MV_USB_SetTransferSize fail! ret[0x%x]" % ret)
    sys.exit()
    # Set number of buffers for U3V stream channels of the SDK
    TransferWay = 2;
    ret = cam.MV_USB_SetTransferWays(TransferWay)
    if ret != 0:
    print ("MV_USB_SetTransferWays fail! ret[0x%x]" % ret)
    sys.exit()


Exclusive Configuration of Serial Port Devices

Serial port device is connected via serial port, and the communication protocol complies with GenCP. For this type of device, you can call MV_CAMERALINK_DEVICE() for enumeration.
Note
Serial port devices include light controller and Camera Link cameras.
When the device communicates through serial ports, you can change the baud rate to improve transmission speed. Details are as follows:
  1. Call MV_CAML_GetSupportBaudrates() to get the supported baud rate of between the device and host.
  2. Call MV_CAML_SetDeviceBaudrate() to set the baud rate of the device.
# Get the supported baud rate between the device and the host
BaudrateAblity = ctypes.c_int(0)
ret = cam.MV_CAML_GetSupportBaudrates(BaudrateAblity)
if ret != 0:
print ("MV_CAML_GetSupportBaudrates fail! ret[0x%x]" % ret)
sys.exit()
# Check if it is supported to set baud rate to 115200. If yes, set it to 115200
if BaudrateAblity & MV_CAML_BAUDRATE_115200:
ret = cam.MV_CAML_SetDeviceBaudrate(MV_CAML_BAUDRATE_115200)
if ret != 0:
print ("MV_CAML_SetDeviceBaudrate fail! ret[0x%x]" % ret)
sys.exit()